Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error = { required r(100)

    Greetings Please attached is my do file that I am trying to use to test associations between my explanatory and response variables.
    But I keep getting the "{ required r(100)" code.
    I need some help. Being stuck for a while.
    Best
    Attached Files

  • #2
    Welcome to Statalist. It is better not to attach files here. (Graphs are an exception as there is no good alternative.) Better is to copy your code from the do-file and paste it here into the forum editor, wrapping it in code delimiters. If you are not familiar with code delimiters, read Forum FAQ #12 for instructions on how to use them.

    Some responders are unwilling to take the risk of downloading anything from a stranger.

    Comment


    • #3
      Clyde gives good advice.

      Based on what you describe, and on a problem frequently reported on Statalist, I am going to guess that your do-file includes continuation lines, and that you ran the commands in your do-file by copying them from the do-file and pasting them into Stata's Command window. That will not work because line continuation using "///" is programming syntax that Stata supports only when commands are run directly from a do-file. My guess is that Stata got to the end of a line that it was expecting to end with "{" and instead it ended with "///".

      If you have the do-file open in the Do-file Editor window, click the "Run" icon on the toolbar to submit it to be run.

      Comment


      • #4
        Hello everyone! I am encountering a similar problem and I hope to get a solution. It seems like a simple trick which I am unable to get at. I am trying to to do a sensitivity analysis using regsensitivity command (Diegart et al. 2022). For understanding the concept, I am using Bazzi et al.(2020) data as is mentioned in their user code manual. I am replicating their steps exactly. I have defined local macros to list the variable names and ran the regression, which worked perfectly. But once I specify the regsensitivity command (already installed in Stata 15), I am getting the error code (100) varlist required. I have specified the same macros here as I did while running the regression, but it seems like Stata doesn't know what variables to recall. I am pasting the do-file codes for your reference.

        sysuse bfg2020, clear

        local y avgrep2000to2016

        local x tye_tfe890_500kNI_100_l6

        local w1 log_area_2010 lat lon temp_mean rain_mean elev_mean d_coa d_riv d_lak ave_gyi

        local w0 i.statea

        local w `w1' `w0'

        local SE cluster( km_grid_cel_code )

        reg `y' `x' `w', `SE'

        regsensitivity `y' `x' `w', compare(`w1')


        varlist required
        r(100);

        end of do-file

        r(100);

        Comment


        • #5
          Are you running this code, without interruption, from beginning to end? If you are going in chunks, then the local macros go out of scope, i.e. become undefined, at the end of a chunk. And that would lead to the kind of error message you are encountering. The code must be run without interrupt from beginning to end.

          Comment


          • #6
            Hi Clyde, Thanks for your reply. Yes, I am running all the codes starting from defining the variables upto the regression together. From the do file, I execute the following codes at one go.
            sysuse bfg2020, clear

            local y avgrep2000to2016

            local x tye_tfe890_500kNI_100_l6

            local w1 log_area_2010 lat lon temp_mean rain_mean elev_mean d_coa d_riv d_lak ave_gyi

            local w0 i.statea

            local w `w1' `w0'

            local SE cluster( km_grid_cel_code )

            reg `y' `x' `w', `SE'

            But if I also run the regsensitivity code together with the above codes, I get an invalid syntax error message.
            regsensitivity `y' `x' `w', compare(`w1')

            invalid syntax
            r(198);

            end of do-file

            r(198);
            But if I run the regsensitivity command separately immediately after running the regression, then I get the varlist required error code (100) which is what I mentioned in the previous post. Would seek your observation on this.

            Comment


            • #7
              I am also assuming that regsensititvity must be preceded by a regression to work, since it is like a postestimation activity. But I do not know if by the time the regression is executed the local macros vanish and hence running regsensitivity cannot identify the previously defined local macros.

              Comment


              • #8
                -regress- won't cause the local macros to go out of scope. So something is going on inside regsensitivity to cause the problem. It's a user-written command, and one that I'm not familiar with. Here's what I would do. Between the -regress- and -regsensitivity- commands add the following commands:
                Code:
                set tracedepth 1
                set trace on
                Run everything, uninterrupted, from beginning to end. When -regsensitivity- comes in, you will be able to see what is going on inside -regsensitivity- and where it is throwing the syntax error. It may or may not be clear from that what the problem is. If it's not clear, then post the output here and maybe we can figure it out.

                Comment


                • #9
                  Hi Clyde. Thanks for the suggestion. When I add those two lines and execute the above codes from the very beginning till regsensitivity, now regsensitivity does show some output but the output again shows the invalid syntax error. I am pasting the output here. I feel some trick will definitely resolve the problem as we are going closer to the results.


                  regsensitivity `y' `x' `w' , compare(`w1')
                  --------------------------------------------------------------------------------------- begin regsensitivity ---
                  - version 15
                  - local subcommands bounds breakdown plot
                  - gettoken subcommand 0 : 0
                  - if regexm("`subcommand'", ",$"){
                  = if regexm("avgrep2000to2016", ",$"){
                  local subcommand = substr("`subcommand'", 1, strlen("`subcommand'") - 1)
                  local 0 ,`0'
                  }
                  - local issubcommand : list subcommand in subcommands
                  - if(!`issubcommand'){
                  = if(!0){
                  - local 0 `subcommand' `0'
                  = local 0 avgrep2000to2016 tye_tfe890_500kNI_100_l6 log_area_2010 lat lon temp_mean rain_mean elev_mean d_coa d
                  > _riv d_lak ave_gyi i.statea , compare(log_area_2010 lat lon temp_mean rain_mean elev_mean d_coa d_riv d_lak ave_
                  > gyi)
                  - local subcommand summary
                  - }
                  - local plot plot
                  - local ploton : list plot in 0
                  - local 0 : list 0 - plot
                  - local plot `ploton'
                  = local plot 0
                  - if("`subcommand'" != "plot"){
                  = if("summary" != "plot"){
                  - quietly load_dgp `0'
                  = quietly load_dgp avgrep2000to2016 tye_tfe890_500kNI_100_l6 log_area_2010 lat lon temp_mean rain_mean elev_mean
                  > d_coa d_riv d_lak ave_gyi i.statea , compare(log_area_2010 lat lon temp_mean rain_mean elev_mean d_coa d_riv d_
                  > lak ave_gyi)
                  - }
                  - if("`subcommand'" == "summary"){
                  = if("summary" == "summary"){
                  - summary `0'
                  = summary avgrep2000to2016 tye_tfe890_500kNI_100_l6 log_area_2010 lat lon temp_mean rain_mean elev_mean d_coa d_
                  > riv d_lak ave_gyi i.statea , compare(log_area_2010 lat lon temp_mean rain_mean elev_mean d_coa d_riv d_lak ave_g
                  > yi)

                  invalid syntax
                  }
                  ----------------------------------------------------------------------------------------- end regsensitivity ---
                  r(198);

                  end of do-file

                  r(198);

                  On the other hand if I run the regression and after that add the two lines and execute regsensitivity along with these at one go, then I get the varlist required error (100). Also I am adding no continuation lines (///) in any of the codes.

                  Comment


                  • #10
                    On the other hand if I run the regression and after that add the two lines and execute regsensitivity along with these at one go, then I get the varlist required error (100).
                    Well, there is no surprise here. If you stop after the regression, the local macros go out of scope. Consequently when you then call -regsensitivity-, your `y', `x', `w', and `w1' are all empty and -regsensitivity- notices the absence of any specified variables. This sort of thing typically happens if you try to run code that uses a local macro separately from the code that defines it. So we can ignore that varlist required error: that one's on you.

                    But the -syntax error- message is not attributable to anything obvious you might be doing wrong. Unfortunately, the problem is coming from somewhere deeper inside -regsensitivity- than was revealed by the depth 1 trace. I am not familiar with -regsensitivity- and would not be doing anybody a favor by trying to hack deeper into it. This thread has gone on a few days and nobody else on the Forum has jumped in with a solution. So I think at this point your best bet is to contact the authors of -regsensitivity- and ask for their help. Provide them with the same information you have given in #6 and #9. Their names and contact information, according to SSC, are:
                    Code:
                          Author: Paul Diegert, Duke University
                          Support: email [email protected]
                          
                          Author: Matthew A. Masten, Duke University
                          Support: email [email protected]
                          
                          Author: Alexandre Poirier,  Georgetown University
                          Support: email [email protected]

                    Comment


                    • #11
                      Hi Clyde. I agree with you on this point. Let me contact the authors first, and I shall get back to here with some update.

                      Comment

                      Working...
                      X